package xyz.kongbai121.demo.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Objects;

/**
 * 用户实体类
 * @author 空白
 */
@Getter
@Setter
@ToString
public class User {
    @TableId(type = IdType.AUTO)
    private Long id;                            //用户id
    private String openid;                      //唯一标识
    private Integer admin = 0;                  //管理员权限
    private Integer state = 1;                  //账号状态
    private String nickName;                    //用户名
    private String avatarUrl;                   //用户头像
    private String gender;                      //性别
    private String province;                    //登录地
    private Integer articleNum = 0;             //文章发布数
    private Integer treeHoleNum = 0;            //树洞发布数
    private Integer unreadComment = 0;          //未读评论数
    private Integer unreadOpinion = 0;          //未读意见数

    public User() {
    }

    public User(String openid, String nickName, String avatarUrl, String gender, String province) {
        this.openid = openid;
        this.nickName = nickName;
        this.avatarUrl = avatarUrl;
        this.gender = gender;
        this.province = province;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(openid, user.openid) &&
                Objects.equals(nickName, user.nickName) &&
                Objects.equals(avatarUrl, user.avatarUrl) &&
                Objects.equals(gender, user.gender) &&
                Objects.equals(province, user.province);
    }

    @Override
    public int hashCode() {
        return Objects.hash(openid, nickName, avatarUrl, gender, province);
    }
}
